<template>
	<view class="u-page">
		<view class="user-info">
			<u-avatar :src="store.logoImage" default-url="/static/logo.png" size="74"/>
			<view class="line-white mt-20">
				<text>{{userInfo.userName}} | {{userInfo.phone}}</text>
			</view>
		</view>
		<view>
			<view class="" v-for="(menu, mIx) in menuList" :key="mIx" @click="rowClick(menu)">
				<my-cell-group 
					:title="menu.title" 
					icon-type="hollow" 
					:icon="menu.icon"
					icon-color="#e54d42" 
					:url="menu.url" 
					:disabled="!menu.url"
				/>
			</view>
		</view>
	</view>
	
</template>

<script>
	import {mapState, mapMutations} from 'vuex'
	import myCellGroup from '@/components/my-cell-group/index.vue'
	export default {
		components:{ myCellGroup },
		data() {
			return {
				menuList:[
					{title:'个人信息', icon:'icon-gerenxinxi', url:'/pages/editProfile/index'},
					// {title:'门店资料', icon:'icon-shop08', url:'/pages/shop/default/edit?type=2&&id=' + this.store.id},
					{title:'切换身份', icon:'icon-qh2', url:'/pages/my/changeRole?type=1'},
					{title:'切换门店', icon:'icon-dianpu', url:'/pages/my/changeRole?type=2'},
					{title:'修改密码', icon:'icon-bianji', url:'/pages/editProfile/password'},
					{title:'扫会员码', icon:'icon-qrcode'},
					{title:'退出登录', icon:'icon-tuichu'},
					// {title:'关于', icon:'icon-about', url:'/pages/about/index'}
				]
			}
		},
		onLoad() {
		},
		computed: {
			...mapState(['userInfo','store'])
		},
		methods: {
			...mapMutations(['logout']),
			rowClick(row){
				const that = this
				if(row.title === '退出登录'){
					uni.showModal({
						title: '提示',
						content: '确定退出登录吗?',
						success: function (res) {
							if (res.confirm) {
								that.logout()
								uni.reLaunch({
									url:'/pages/login/login'
								})
							}
						}
					})
				}else if(row.title === '扫会员码'){
					// that.$reqJsonPost('GetStoreQrCode', {id: this.store.id}).then(res=>{
					// 	uni.previewImage({
					// 		urls: [res.data.data]
					// 	})
					// })
					let _this = this
					uni.scanCode({
						success: function (res) {
							const id = res.path.split("scene=")[1]
							_this.$reqJsonPost('SetUserStoreShare', {id: id}).then(res=>{
								_this.$u.toast('扫码成功!')
							})
						}
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.u-page{ 
		background-image: url('/static/images/usercenter_bg.png'); 
		background-size: 100% auto; 
		background-repeat: no-repeat;
		.user-info{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			min-height:460rpx;
		}
	}
</style>